﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace HarveyNash.RefactoringAndCodeSmell.Refactoring.ConsolidateDuplicateConditionalFragments
{
    public class After
    {
        public void ProcessApprovalAction(int leaveRequestId, bool approved)
        {
            MailMessage message;
            if (approved)            
                message = CreateEmail(leaveRequestId, GetApproveSubject(), GetApproveBody());    
            else            
                message = CreateEmail(leaveRequestId, GetRejectSubject(), GetRejectBody());
            SendMail(message);            
        }

        public MailMessage CreateEmail(int leaveRequestId, string subject, string body)
        {
            MailMessage message = new MailMessage();
            message.From = GetRecipientAddress(leaveRequestId);
            message.To.Add("leavesystem@harveynash.vn");
            message.Subject = subject;
            message.Body = body;
            return message;
        }

        private MailAddress GetRecipientAddress(int leaveRequestId)
        {
            //GetRecipientAddress code
            //...
            throw new NotImplementedException();
        }

        private string GetRejectBody()
        {
            //GetRejectBody code
            //...
            throw new NotImplementedException();
        }

        private string GetRejectSubject()
        {
            //GetRejectSubject code
            //...
            throw new NotImplementedException();
        }

        private string GetApproveBody()
        {
            //GetApproveBody code
            //...
            throw new NotImplementedException();
        }

        private string GetApproveSubject()
        {
            //GetApproveSubject code
            //...
            throw new NotImplementedException();
        }     

        private void SendMail(MailMessage message)
        {
            //send mail 
            //...
            throw new NotImplementedException();
        }
    }
}
